import os
def process_string():
  url_input = raw_input("Enter url :")
  #keywords_imput=raw_input("Enter the keywords :")
  #category_input=raw_input("Enter category:")
  values=url_input.split(',')
  if(len(values)>0):
    print "ok"
    url=values[0]
    key=values[1].split()
    category=values[2].split()
    desc=values[3]	
    store(url,key,category,desc)
  menu()

def store(url,key,category,desc):
  f=open('um_db.txt','a')
  f.writelines("\n<*entry*>\n")
  f.writelines("<*url*>"+url+"<*/url*>\n")
  f.writelines("<*keywords*>\n")
  for e in key:
    f.writelines("<*keyword*>"+e+"<*keyword*>\n")
  f.writelines("<*/keywords*>\n")
  f.writelines("<*categories*>\n")
  for t in category :
    f.writelines("<*category*>"+t+"<*category*>\n")
  f.writelines("<*categories*>\n")
  f.writelines("<*description*>"+desc+"<*description*>\n")
  f.writelines("<*entry*>\n")
  f.close()
  

def menu():
  continue_option=raw_input("Check menu option:")
  if(continue_option=="1"):
    process_string()
  
#  switch(continue_option):
 #   case '1':
  #    process_string()
   # case '2':
    #  menu()
   # default :
    #  menu()

def prelim_check():
  if(os.path.isfile('um_db.txt')==False):
    f=  open('um_db.txt','w')
    f.close()
  

if __name__=='__main__' :
  prelim_check();
  process_string();
  

